﻿using System;
using System.Linq;

namespace Model.Core.DataBase
{
    /// <summary>
    ///     数据上下文接口
    /// </summary>
    public interface IDbContext : IDisposable
    {
        /// <summary>
        ///     隐式事务提交,将此上下文中的所作的所有更改进行保存
        /// </summary>
        /// <returns>操作结果数</returns>
        int SaveAllChange();


        /// <summary>
        ///     获取实体的操作
        /// </summary>
        /// <typeparam name="TEntity">要查询的实体类</typeparam>
        /// <returns>数据操作接口</returns>
        IOperator<TEntity> GetOperator<TEntity>() where TEntity : class;

        /// <summary>
        ///     获取实体的Linq,方便复合查询
        /// </summary>
        /// <typeparam name="TEntity">要查询的实体类</typeparam>
        /// <returns>数据查询接口</returns>
        IQueryable<TEntity> Queryable<TEntity>() where TEntity : class;
    }
}